﻿using System.Data.Linq;
using System.Data.Linq.Mapping;

namespace BSU.GraduateWork.Data.Model
{
    [Table(Name = "SolutionPoints")]
    public class SolutionPoint2D: SolutionPoint
    {
        [Column(Name = "id", DbType = "Int IDENTITY", IsPrimaryKey = true, IsDbGenerated = true,
            CanBeNull = false, AutoSync = AutoSync.OnInsert, UpdateCheck = UpdateCheck.Never)]
        public override int Id { get; set; }

        private EntityRef<Solution2D> _Solution;

        [Column(Name = "SolutionId", DbType = "Int", CanBeNull = false, UpdateCheck = UpdateCheck.Never)]
        internal int SolutionId { get; set; }

        [Column(Name = "U", DbType = "float", CanBeNull = false, UpdateCheck = UpdateCheck.Never)]
        public override double U { get; set; }

        [Column(Name = "IsBoundary", DbType = "Bit", CanBeNull = false, UpdateCheck = UpdateCheck.Never)]
        public override bool IsBoundary { get; set; }

        [Association(Storage = "_Solution", ThisKey = "SolutionId")]
        public Solution2D Solution
        {
            get { return _Solution.Entity; }
            set {_Solution.Entity = value; }
        }

        [Column(Name = "X", DbType = "float", CanBeNull = false, UpdateCheck = UpdateCheck.Never)]
        public double X { get; set; }

        [Column(Name = "Y", DbType = "float", CanBeNull = false, UpdateCheck = UpdateCheck.Never)]
        public double Y { get; set; }
    }
}
